Optimal. Leaf size=61 \[ \frac{2 \sqrt{a^2-b^2} \tanh ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{a b}-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.176036, antiderivative size = 61, normalized size of antiderivative = 1., number of steps used = 8, number of rules used = 8, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.615, Rules used = {3894, 4051, 3770, 3919, 3831, 2660, 618, 206} \[ \frac{2 \sqrt{a^2-b^2} \tanh ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{a^2-b^2}}\right )}{a b}-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3894
Rule 4051
Rule 3770
Rule 3919
Rule 3831
Rule 2660
Rule 618
Rule 206
Rubi steps
\begin{align*} \int \frac{\cot ^2(x)}{a+b \csc (x)} \, dx &=\int \frac{-1+\csc ^2(x)}{a+b \csc (x)} \, dx\\ &=\frac{\int \csc (x) \, dx}{b}+\frac{\int \frac{-b-a \csc (x)}{a+b \csc (x)} \, dx}{b}\\ &=-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b}-\left (\frac{a}{b}-\frac{b}{a}\right ) \int \frac{\csc (x)}{a+b \csc (x)} \, dx\\ &=-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b}-\frac{\left (\frac{a}{b}-\frac{b}{a}\right ) \int \frac{1}{1+\frac{a \sin (x)}{b}} \, dx}{b}\\ &=-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b}-\frac{\left (2 \left (\frac{a}{b}-\frac{b}{a}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{1+\frac{2 a x}{b}+x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )}{b}\\ &=-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b}+\frac{\left (4 \left (\frac{a}{b}-\frac{b}{a}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{-4 \left (1-\frac{a^2}{b^2}\right )-x^2} \, dx,x,\frac{2 a}{b}+2 \tan \left (\frac{x}{2}\right )\right )}{b}\\ &=-\frac{x}{a}-\frac{\tanh ^{-1}(\cos (x))}{b}+\frac{2 \sqrt{a^2-b^2} \tanh ^{-1}\left (\frac{b \left (\frac{a}{b}+\tan \left (\frac{x}{2}\right )\right )}{\sqrt{a^2-b^2}}\right )}{a b}\\ \end{align*}
Mathematica [A] time = 0.0676879, size = 71, normalized size = 1.16 \[ \frac{2 \sqrt{b^2-a^2} \tan ^{-1}\left (\frac{a+b \tan \left (\frac{x}{2}\right )}{\sqrt{b^2-a^2}}\right )+a \log \left (\sin \left (\frac{x}{2}\right )\right )-a \log \left (\cos \left (\frac{x}{2}\right )\right )-b x}{a b} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A] time = 0.064, size = 105, normalized size = 1.7 \begin{align*} -2\,{\frac{\arctan \left ( \tan \left ( x/2 \right ) \right ) }{a}}+{\frac{1}{b}\ln \left ( \tan \left ({\frac{x}{2}} \right ) \right ) }-2\,{\frac{a}{b\sqrt{-{a}^{2}+{b}^{2}}}\arctan \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) +2\,a}{\sqrt{-{a}^{2}+{b}^{2}}}} \right ) }+2\,{\frac{b}{a\sqrt{-{a}^{2}+{b}^{2}}}\arctan \left ( 1/2\,{\frac{2\,b\tan \left ( x/2 \right ) +2\,a}{\sqrt{-{a}^{2}+{b}^{2}}}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A] time = 0.590871, size = 539, normalized size = 8.84 \begin{align*} \left [-\frac{2 \, b x + a \log \left (\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) - a \log \left (-\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) - \sqrt{a^{2} - b^{2}} \log \left (\frac{{\left (a^{2} - 2 \, b^{2}\right )} \cos \left (x\right )^{2} + 2 \, a b \sin \left (x\right ) + a^{2} + b^{2} + 2 \,{\left (b \cos \left (x\right ) \sin \left (x\right ) + a \cos \left (x\right )\right )} \sqrt{a^{2} - b^{2}}}{a^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right )}{2 \, a b}, -\frac{2 \, b x + a \log \left (\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) - a \log \left (-\frac{1}{2} \, \cos \left (x\right ) + \frac{1}{2}\right ) - 2 \, \sqrt{-a^{2} + b^{2}} \arctan \left (-\frac{\sqrt{-a^{2} + b^{2}}{\left (b \sin \left (x\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \cos \left (x\right )}\right )}{2 \, a b}\right ] \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F] time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\cot ^{2}{\left (x \right )}}{a + b \csc{\left (x \right )}}\, dx \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.30169, size = 108, normalized size = 1.77 \begin{align*} -\frac{x}{a} + \frac{\log \left ({\left | \tan \left (\frac{1}{2} \, x\right ) \right |}\right )}{b} - \frac{2 \,{\left (\pi \left \lfloor \frac{x}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (b\right ) + \arctan \left (\frac{b \tan \left (\frac{1}{2} \, x\right ) + a}{\sqrt{-a^{2} + b^{2}}}\right )\right )}{\left (a^{2} - b^{2}\right )}}{\sqrt{-a^{2} + b^{2}} a b} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]